GX 03 - QuickDraw GX and Color Profiles (1-May-95)
Q Do I need to call GXCloneColorProfile before calling GXConvertColor?
Since the color passed into GXConvertColor by ColorSync is destroyed, should
the color profile passed in as part of the color be disposed? If not, isn't
that a memory leak?
A Calling GXCloneColorProfile is not necessary, and it would require additional
work that does not need to be done. gxColor is a public data structure, not an
object. The application, not GX, handles adding/maintaining references to
objects with respect to gxColor's (and gxBitmaps). GX maintains owner counts
when the profile is attached to another GX object (using GXNewBitmap,
GXSetInkColor, etc.). This is not a memory leak.
For example, consider this scenario:
When an application gets a shape's color, the ink's profile has two owners --
the shape and the application. Therefore, the application can reference the
profile in gxColor structures, even if the shape is disposed. Once the
application calls GXDisposeColorProfile, the reference is no longer valid.
Cloning the color profile does nothing except to require that
GXDisposeColorProfile be called afterward. As a result, all that happens is
that time is wasted as the owner count goes from a positive number to that
number plus 1, and then back down.